package com.cctc.security.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.cctc.framework.dao.BaseDao;
import com.cctc.security.domain.Resource;
import com.cctc.security.util.SqlUtil;

@Repository
public class ResourceDao<T extends Resource> extends BaseDao<Object> {

	public void addResource(T t) {
		save(t);
	}

	public void delResource(T t) {
		delete(t);
	}

	public void updateResource(T t) {
		update(t);
	}

	public Resource findResourceById(String id) {
		return this.getHibernateTemplate().get(Resource.class, id);
	}
	
    public List<?> getResourcesUrlByAuthoritieName(String authoritieName){
	    return this.findByNamedQuery(SqlUtil.NAME_GET_RESOURCE_URL_BY_AUTHORITE_NAME, authoritieName);
	}
}
